﻿using Sidvall.Serialization;

namespace Sidvall.AuthorizationManager.Data.Keys
{
    public class UserIndex
    {
        public string UserId { get; set; }
        
        public static UserIndex GetKey(IAuthorizationScopeUser item)
        {
            if (item == null)
                return null;
            if (item.UserId == null)
                return null;
            return new UserIndex()
            {
                UserId = item.UserId,
            };
        }
        public static UserIndex GetKey(string userId)
        {
            if (userId == null)
                return null;
            return new UserIndex()
            {
                UserId = userId,
            };
        }
        public static UserIndex ParseKey(string key)
        {
            return new UserIndex()
            {
                UserId = key,
            };
        }
        public override string ToString()
        {
            return this.UserId;
        }
    }
}